package com.rzjm.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.rzjm.api.dao.UserMpMapper;
import com.rzjm.api.entity.User;
import com.rzjm.api.entity.UserMp;
import com.rzjm.api.service.UserMpService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserMpServiceImpl extends BaseServiceImpl<UserMpMapper, UserMp> implements UserMpService {

    @Resource
    private UserMpMapper userMpMapper;

    @Override
    public UserMp getLastUserMp() {
        QueryWrapper<UserMp> qw = new QueryWrapper<>();
        qw.orderByDesc("id");
        qw.last("limit 1");
        return userMpMapper.selectOne(qw);
    }


    @Override
    public UserMp getUserMp(User user) {
        QueryWrapper<UserMp> qw = new QueryWrapper<>();
        qw.eq("union_id",user.getUnionId());
        qw.last("limit 1");
        return userMpMapper.selectOne(qw);
    }
}
